package controller

import (
	"encoding/json"
	"go-template-demo/model"
	"log"
	"net/http"
)

type Search struct {
	Id   float64 `json:"id"`
	Name string  `json:"name"`
}

func registerSearchRouters() {
	http.HandleFunc("/search", handleSearch)
}

func handleSearch(w http.ResponseWriter, r *http.Request) {
	s := model.Student{
		ID:         1000,
		Name:       "zhangsan",
		Age:        16,
		Permission: true,
	}

	enc := json.NewEncoder(w)
	err := enc.Encode(s)
	if err != nil {
		log.Println(err.Error())
		w.WriteHeader(http.StatusInternalServerError)
		return
	}
}
